<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>移入移出js</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .d {
            width: 80%;
            height: 400px;
            margin: 30px auto;
            border: 1px dotted pink;
        }
        .d2{
            width: 150px;
            height: 100px;
            background-color: chartreuse;
        }
        .d3{
            width: 150px;
            height: 100px;
            background-color: aqua;
            display: none;
        }
    </style>
</head>
<body>
<div class="d">
    <div class="d1">鼠标移入移出&显示与隐藏:</div>
    <div class="d2">移入移出</div>
    <div class="d3">显示&隐藏</div>
</div>
<script>
    (function () {
        var d2=document.getElementsByClassName("d2")[0];
        d2.onmouseover=function () {
            var d3=document.getElementsByClassName("d3")[0];
            d3.style.display="block";
        }
        d2.onmouseout=function () {
            var d3=document.getElementsByClassName("d3")[0];
            d3.style.display="none";
        }

    })();
</script>
</body>
</html>